package com.woke.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.woke.data.UserPromoteCode;
import com.zhongcai.online.R;

import me.drakeet.multitype.ItemViewProvider;

/**
 * 作者 ： 暗网
 * 创建时间：2017/2/14
 * 备注：
 */

public class PromoteCodeViewProvider extends ItemViewProvider<UserPromoteCode, PromoteCodeViewProvider.ViewHolder> {

	private OnItemClickListener mItemClickListener;

	public PromoteCodeViewProvider(OnItemClickListener listener) {
		mItemClickListener = listener;
	}

	@NonNull
	@Override
	protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
		View itemView = inflater.inflate (R.layout.adapter_activity_userpromote_item, parent, false);
		return new ViewHolder (itemView);
	}

	@Override
	protected void onBindViewHolder(@NonNull final ViewHolder holder, @NonNull final UserPromoteCode info) {

		holder.textView.setText (info.getName ());
		holder.itemView.setOnClickListener (new View.OnClickListener () {
			@Override
			public void onClick(View v) {
				if (mItemClickListener != null) {
					mItemClickListener.OnItemClick (v, getPosition (holder));
					mItemClickListener.OnItemClick (v, info, getPosition (holder));
				}
			}
		});

	}

	class ViewHolder extends RecyclerView.ViewHolder {


		private TextView textView;

		public ViewHolder(View itemView) {
			super (itemView);
			textView = (TextView) itemView
					.findViewById (R.id.textView);
		}


	}
}
